﻿namespace Hotel.ModulesTest
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using ManagementModule = Hotel.Module.Management;
    using System.Collections.Generic;

    [TestClass]
    class ApplyAssignmentTestClass
    {
        [TestMethod]
        public void ApplyAssignmentTest()
        {
            Preparator.Prepare("ApplyAssignment");

            using (ManagementModule.ManagementController m_ManagementController = Hotel.Web.Helpers.ServiceLocator.Instance.GetService(typeof(ManagementModule.IManagement)) as ManagementModule.ManagementController)
            {
                ManagementModule.Models.Assignment _neededAssignment = new ManagementModule.Models.Assignment{ Description = "Some Description 0", State = ManagementModule.Models.AssignmentState.Applied, ID = 1, WorkerLogin = "Janitor 0", RoomNumber = 1, ServiceID = 1, WorkerType = ManagementModule.Models.Assignment.CurrWorkerType.Cleaners };

                m_ManagementController.ApplyAssignment(_neededAssignment);                
            }

            using (ManagementModule.ManagementController m_ManagementController = Hotel.Web.Helpers.ServiceLocator.Instance.GetService(typeof(ManagementModule.IManagement)) as ManagementModule.ManagementController)
            {
                List<ManagementModule.Models.Assignment> _listOfAssignments = m_ManagementController.GetCurrentAssignments("Janitor 0");

                Assert.IsTrue(_listOfAssignments.Count == 1);
            }            
        }
    }
}
